import QtQuick 2.0
import QtQuick.Window 2.2
import QtQuick.Controls 1.1
import QtQuick.Layouts 1.0

ApplicationWindow {
    id: mainWindow
    visible: true
    width: 400
    height: 600
    title: qsTr("Like Music")
    menuBar: MenuBar {
        Menu {
            title: "file"
            MenuItem {
                text: "open..."
                shortcut: "Ctrl+O"
                onTriggered: {
                    windowModel.open()
                }
            }
        }
    }

    Rectangle {
        id: centralRect
        width: mainWindow.width
        height: mainWindow.height
        MusicView {
            id: musicView
            visible: true
            width: centralRect.width
            height: centralRect.height
        }
        PlayerControls {
            id: playerControls
            visible: false
            width: centralRect.width
            height: centralRect.height
        }
    }
    statusBar: StatusBar {
        RowLayout {
            anchors.fill: parent
            Label {
                id: statusLabel
                text: "Ready"
            }
        }

        Connections {
            target: windowModel
            onMessageChanged: {
                statusLabel.text = message
            }
        }
    }

    Connections {
        target: musicView
        onSelected: {
            musicView.state = "close"
            playerControls.state = "open"
        }
    }
    Connections {
        target: playerControls
        onBack: {
            musicView.state = "open"
            playerControls.state = "close"
        }
    }
}
